package com.wen.common.config;

import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author Devin QQ:1441289544
 * @create 2022-04-08 14:06
 *
 * swagger2配置类
 */
//@Configuration
@EnableSwagger2 //开启swagger
public class Swagger2Config {

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                //加载swagger 扫描包
                .apis(RequestHandlerSelectors.basePackage("com.wen.controller"))
//                .paths(PathSelectors.any())
                .build()
                .groupName("李文")
                .apiInfo(apiInfo());
    }

    /**
     * 多个docket多个文档api
     */
    @Bean
    public Docket docket1() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("组1");
    }
    @Bean
    public Docket docket2() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("组2");
    }

    public ApiInfo apiInfo() {
        Contact contact = new Contact("Devin", "https://gitee.com/devinsite/springboot", "devinlive@163.com");

        return new ApiInfo("Api Documentation"
                , "Api Documentation"
                , "1.0"
                , "urn:tos"
                , contact
                , "Apache 2.0"
                , "http://www.apache.org/licenses/LICENSE-2.0"
                , new ArrayList());
    }

}
